---
title: "API Reference: Schema Reporting Plugin"
api_reference: true
---

> Note:
> **The schema reporting plugin does not support graphs that use Apollo Federation.** If you are using Federation, or if you want to publish your monolith schema in your CI/CD pipeline, you can use the [Rover CLI to publish your schema or subgraph changes](/graphos/delivery/publishing-schemas).

## Using the plugin

This article documents the options for the `ApolloServerPluginSchemaReporting` plugin, which you can import from `@apollo/server/plugin/schemaReporting`.

This plugin enables your GraphQL server to register its latest schema with the Apollo schema registry every time it starts up. Full details on schema reporting can be found in [the Apollo Studio docs](/graphos/delivery/publishing-schemas).

In order to use this plugin, you must configure your server with a graph API key, either with the `APOLLO_KEY` environment variable or by passing it directly to your `ApolloServer` constructor (e.g., `new ApolloServer({apollo: {key: KEY}})`). This is the same way you configure [usage reporting](./usage-reporting).

You must *explicitly enable* schema reporting. If you want to turn on schema reporting with its default configuration, you can set the `APOLLO_SCHEMA_REPORTING` environment variable to `true`.

If you want to configure schema reporting (or prefer your setup to be via code rather than using environment variables), import the `ApolloServerPluginSchemaReporting` plugin and pass it to the `ApolloServer` constructor:

<MultiCodeBlock>

```ts
import { ApolloServer } from '@apollo/server';
import { ApolloServerPluginSchemaReporting } from '@apollo/server/plugin/schemaReporting';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [
    ApolloServerPluginSchemaReporting(),
  ],
});
```

</MultiCodeBlock>

### Using the plugin with multiple deployment instances

A single instance of Apollo Server running the plugin reports the current schema hash to GraphOS in a heartbeat fashion. This hash is an identifier of the schema version and doesn't incorporate any usage data. GraphOS only reflects a new schema version in the changelog once all Apollo Server instances—whether one or more—are reporting the same schema hash.

## Options

<table class="field-table">
  <thead>
    <tr>
      <th>Name /<br/>Type</th>
      <th>Description</th>
    </tr>
  </thead>

<tbody>

<tr>
<td>


###### `initialDelayMaxMs`

`number`
</td>
<td>

The schema reporter waits before starting reporting. By default, the report waits some random amount of time between 0 and 10 seconds. A longer interval leads to more staggered starts which means it is less likely multiple servers will get asked to upload the same schema.

If this server runs in lambda or in other constrained environments it would be useful to decrease the schema reporting max wait time to be less than default.

This number will be the max for the range in ms that the schema reporter will wait before starting to report.
</td>
</tr>

<tr>
<td>

###### `overrideReportedSchema`

`string`
</td>
<td>

Override the reported schema that is reported to the Apollo registry. This schema does not go through any normalizations and the string is directly sent to the Apollo registry. This can be useful for comments or other ordering and whitespace changes that get stripped when generating a `GraphQLSchema`.

**If you pass this option to this plugin, you should explicitly configure [`ApolloServerPluginUsageReporting`](./usage-reporting/#overridereportedschema) and pass the same value to its `overrideReportedSchema` option.** This ensures that the schema ID associated with requests reported by the usage reporting plugin matches the schema ID that this plugin reports. For example:

```ts
new ApolloServer({
  plugins: [
    ApolloServerPluginSchemaReporting({
      overrideReportedSchema: schema
    }),
    ApolloServerPluginUsageReporting({
      overrideReportedSchema: schema
    }),
  ],
  // ...
})
```

</td>
</tr>

<tr>
<td>

###### `endpointUrl`

`string`
</td>
<td>

The URL to use for reporting schemas. Primarily for testing and internal Apollo use.
</td>
</tr>

<tr>
<td>

###### `fetcher`

`typeof fetch`
</td>
<td>

Specifies which [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) function implementation to use when reporting schemas.
</td>
</tr>

</tbody>
</table>

## Disabling the plugin

The schema reporting plugin is only automatically installed if the `APOLLO_SCHEMA_REPORTING` is set to `true`, so the easiest way to disable the plugin is to avoid setting that environment variable (and to not explicitly install `ApolloServerPluginSchemaReporting`). However, if you'd like to ensure that the schema reporting plugin is not installed in your server (perhaps for a test that might run with arbitrary environment variables set), you can disable schema reporting by installing the `ApolloServerPluginSchemaReportingDisabled` plugin, like so:

<MultiCodeBlock>

```ts
import { ApolloServer } from '@apollo/server';
import { ApolloServerPluginSchemaReportingDisabled } from '@apollo/server/plugin/disabled';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [
    ApolloServerPluginSchemaReportingDisabled(),
  ],
});
```

</MultiCodeBlock>
